#define _CRT_SECURE_NO_WARNINGS 1

class Solution {
public:
    int findLucky(vector<int>& arr) {
        vector<int> count(510);
        for (auto& e : arr)
        {
            count[e]++;
        }
        for (int i = count.size() - 1; i > 0; i--)
        {
            if (count[i] == i)
                return i;
        }
        return -1;
    }
};